#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101

#include <Macros.h>
#include <CoVector.h>
#include <CoMatrix.h>
#include <CoCube.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/Instruments/Swap.h>
#pragma unmanaged 
#include <ql\instruments\zerocouponinflationswap.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;

using namespace Cephei::QL::Times;
using namespace Cephei::QL;
using namespace Cephei::QL::Indexes;
#define HANDLE
#undef ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Instruments {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of IZeroCouponInflationSwap
	public ref class CZeroCouponInflationSwap : 
            public CSwap,
            public Cephei::QL::Instruments::IZeroCouponInflationSwap
	{
	protected: 
		boost::shared_ptr<QuantLib::ZeroCouponInflationSwap>* _ppZeroCouponInflationSwap;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::ZeroCouponInflationSwap>* _phZeroCouponInflationSwap;
#endif
		Object^ _ZeroCouponInflationSwapOwner;     // reference to object that manages the storage for this object
	internal:
		CZeroCouponInflationSwap (QL::Instruments::ZeroCouponInflationSwap::TypeEnum type, Double nominal, DateTime startDate, DateTime maturity, Cephei::QL::Times::ICalendar^ fixCalendar, QL::Times::BusinessDayConventionEnum fixConvention, Cephei::QL::Times::IDayCounter^ dayCounter, Double fixedRate, Cephei::QL::Indexes::IZeroInflationIndex^ infIndex, Cephei::QL::Times::IPeriod^ observationLag, Microsoft::FSharp::Core::FSharpOption<Boolean>^ adjustInfObsDates, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::ICalendar^>^ infCalendar, Microsoft::FSharp::Core::FSharpOption<QL::Times::BusinessDayConventionEnum>^ infConvention, Cephei::QL::IPricingEngine^ QL_Pricer);
        CZeroCouponInflationSwap (boost::shared_ptr<QuantLib::ZeroCouponInflationSwap>& childNative, Object^ owner);
        CZeroCouponInflationSwap (QuantLib::ZeroCouponInflationSwap& childNative, Object^ owner);
        CZeroCouponInflationSwap (CZeroCouponInflationSwap^ copy);
        CZeroCouponInflationSwap (System::Type^ t);
#ifdef STRUCT
        CZeroCouponInflationSwap (QuantLib::ZeroCouponInflationSwap childNative);
#endif       
#ifdef HANDLE
		CZeroCouponInflationSwap (QuantLib::Handle<QuantLib::ZeroCouponInflationSwap>& childNative, Object^ owner);
		CZeroCouponInflationSwap (QuantLib::Handle<QuantLib::ZeroCouponInflationSwap> childNative);
#endif
		virtual ~CZeroCouponInflationSwap ();
		!CZeroCouponInflationSwap ();

	internal:
		QuantLib::ZeroCouponInflationSwap& GetReference ();
		boost::shared_ptr<QuantLib::ZeroCouponInflationSwap>& GetShared ();
		QuantLib::ZeroCouponInflationSwap* GetPointer ();
        void SetZeroCouponInflationSwap (boost::shared_ptr<QuantLib::ZeroCouponInflationSwap> native)
        {
            if (_ppZeroCouponInflationSwap != NULL)
                delete _ppZeroCouponInflationSwap;
            _ppZeroCouponInflationSwap = new boost::shared_ptr<QuantLib::ZeroCouponInflationSwap> (native);
            SetSwap (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppZeroCouponInflationSwap));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::ZeroCouponInflationSwap>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
        property Double FairRate 
        {
		    virtual Double get () ;
        }
        property Double FixedRate 
        {
		    virtual Double get () ;
        }
        property Cephei::QL::Times::IDayCounter^ DayCounter 
        {
		    virtual Cephei::QL::Times::IDayCounter^ get () ;
        }
        property Cephei::IVector<Cephei::QL::ICashFlow^>^ FixedLeg 
        {
		    virtual Cephei::IVector<Cephei::QL::ICashFlow^>^ get () ;
        }
        property Double FixedLegNPV 
        {
		    virtual Double get () ;
        }
        property Cephei::QL::Indexes::IZeroInflationIndex^ InflationIndex 
        {
		    virtual Cephei::QL::Indexes::IZeroInflationIndex^ get () ;
        }
        property Cephei::IVector<Cephei::QL::ICashFlow^>^ InflationLeg 
        {
		    virtual Cephei::IVector<Cephei::QL::ICashFlow^>^ get () ;
        }
        property Double InflationLegNPV 
        {
		    virtual Double get () ;
        }
        property Double Nominal 
        {
		    virtual Double get () ;
        }
        property Cephei::QL::Times::IPeriod^ ObservationLag 
        {
		    virtual Cephei::QL::Times::IPeriod^ get () ;
        }
        property QL::Instruments::ZeroCouponInflationSwap::TypeEnum Type 
        {
		    virtual QL::Instruments::ZeroCouponInflationSwap::TypeEnum get () ;
        }
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
	public ref class CZeroCouponInflationSwap_Factory : public System::MarshalByRefObject,  public IZeroCouponInflationSwap_Factory
	{
	public:
        virtual IZeroCouponInflationSwap^ Create (QL::Instruments::ZeroCouponInflationSwap::TypeEnum type, Double nominal, DateTime startDate, DateTime maturity, Cephei::QL::Times::ICalendar^ fixCalendar, QL::Times::BusinessDayConventionEnum fixConvention, Cephei::QL::Times::IDayCounter^ dayCounter, Double fixedRate, Cephei::QL::Indexes::IZeroInflationIndex^ infIndex, Cephei::QL::Times::IPeriod^ observationLag, Microsoft::FSharp::Core::FSharpOption<Boolean>^ adjustInfObsDates, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::ICalendar^>^ infCalendar, Microsoft::FSharp::Core::FSharpOption<QL::Times::BusinessDayConventionEnum>^ infConvention, Cephei::QL::IPricingEngine^ QL_Pricer);
    };
   
/*Cephei*/ } /*QL*/ } /*Instruments */}
